home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC] / NeXTSTEP 3.3 Dev Intel.iso / NextDeveloper / Headers / appkit / afm.h < prev    next >
C/C++ Source or Header  |  1993-04-29  |  7KB  |  187 lines

  1. /*
  2.     afm.h
  3.     Application Kit, Release 3.1
  4.     Copyright (c) 1988, 1989, 1990, NeXT, Inc.  All rights reserved. 
  5. */
  6.  
  7. #ifndef AFM_H
  8. #define AFM_H
  9.  
  10. /* font attributes to ask the server for */
  11.  
  12. #define NX_FONTHEADER        1
  13. #define NX_FONTMETRICS        2
  14. #define NX_FONTWIDTHS        4
  15. #define NX_FONTCHARDATA        8
  16. #define NX_FONTKERNING        16
  17. #define NX_FONTCOMPOSITES    32
  18.  
  19. #ifdef KANJI
  20. #define NX_BASEFONTMAPPING  -1
  21. #define NX_88MAPPING         2
  22. #define NX_ESCAPEMAPPING     3    /* not implemented */
  23. #define NX_17MAPPING         4
  24. #define NX_97MAPPING         5
  25. #define NX_SUBSVECTORMAPPING 6    /* not implemented */
  26.  
  27. // The following defines are for EUC Japanese encodings.
  28. // The "GR" encoding may change after the Alpha version.
  29. #define NX_SS2 (0x8e)
  30. #define NX_GR (0xa0)
  31. // The following macro computes character width from character code & font metrics information.
  32. #define NX_WCHARWIDTH(fm,code) \
  33.         ( fm->isBaseFont ? \
  34.         (fm->widths[(code)&0xff]) + ((code)&0xFF00 ? fm->widths[((code)>>8)&0xff] : 0.0) : \
  35.         ((!((code)&0xff00)&&((code)&0x80)) ? \
  36.         (fm->widths[(fm->widthsIndex[NX_GR]<<8)|((code)&0xff)]) : \
  37.         (fm->widths[(fm->widthsIndex[((code)>>8)&0xff]<<8)|((code)&0xff)])))
  38. #endif KANJI
  39.  
  40. typedef struct {    /* per character info */
  41.     short charCode;        /* character code, -1 if unencoded */
  42.     unsigned char numKernPairs;    /* #kern pairs starting with this char */
  43.     unsigned char reserved;
  44.     float xWidth;        /* width in X of this character */
  45.     int name;            /* name - an index into stringTable */
  46.     float bbox[4];        /* character bbox */
  47.     int kernPairIndex;        /* index into NXFontMetrics.kerns array */
  48. } NXCharMetrics;
  49.  
  50.  
  51. typedef struct {    /* elements of the ligature array */
  52.     /* all ligatures go here, regardless of if the chars are encoded */
  53.     int firstCharIndex;        /* index into NXFontMetrics.charMetrics */
  54.     int secondCharIndex;    /* index into NXFontMetrics.charMetrics */
  55.     int ligatureIndex;        /* index into NXFontMetrics.charMetrics */
  56. } NXLigature;
  57.  
  58.  
  59. typedef struct {    /* elements of the encoded ligature array */
  60.     /* ligatures only go here if all three chars are encoded */
  61.     unsigned char firstChar;        /* char encoding of first char */
  62.     unsigned char secondChar;        /* char encoding of second char */
  63.     unsigned char ligatureChar;        /* char encoding of ligature */
  64.     unsigned char reserved;
  65. } NXEncodedLigature;
  66.  
  67.  
  68. typedef struct {    /* elements of the kern pair array */
  69.     int secondCharIndex;    /* index into NXFontMetrics.charMetrics */
  70.     float dx;            /* displacement relative to first char */
  71.     float dy;
  72. } NXKernPair;
  73.  
  74.  
  75. typedef struct {    /* elements of the kern X pair array */
  76.     int secondCharIndex;    /* index into NXFontMetrics.charMetrics */
  77.     float dx;            /* X displacement relative to first char */
  78.                 /* Y displacement is implicitly 0 for these */
  79. } NXKernXPair;
  80.  
  81.  
  82. typedef struct {    /* elements of the track kern array */
  83.     int degree;            /* degree of tightness */
  84.     float minPointSize;        /* parameters for this track */
  85.     float minKernAmount;
  86.     float maxPointSize;
  87.     float maxKernAmount;
  88. } NXTrackKern;
  89.  
  90.  
  91. typedef struct {    /* a composite char */
  92.     int compCharIndex;        /* index into NXFontMetrics.charMetrics */
  93.     int numParts;        /* number of parts making up this char */
  94.     int firstPartIndex;        /* index of first part in */
  95.                 /* NXFontMetrics.compositeCharParts */
  96. } NXCompositeChar;
  97.  
  98.  
  99. typedef struct {    /* elements of the composite char array */
  100.     int partIndex;        /* index into NXFontMetrics.charMetrics */
  101.     float dx;            /* displacement of part */
  102.     float dy;
  103. } NXCompositeCharPart;
  104.  
  105.  
  106. /*
  107.  * Font information from Adobe Font Metrics file
  108.  *
  109.  * Do NOT embed this structure in your data structures, length may change.
  110.  */
  111.  
  112. typedef struct _NXFontMetrics {
  113.     char *formatVersion;    /* version of afm file format */
  114.     char *name;            /* name of font for findfont */
  115.     char *fullName;        /* full name of font */
  116.     char *familyName;        /* "font family" name */
  117.     char *weight;        /* weight of font */
  118.     float italicAngle;        /* degrees ccw from vertical */
  119.     char isFixedPitch;        /* is the font mono-spaced? */
  120.     char isScreenFont;        /* is the font a screen font? */
  121.     short screenFontSize;    /* If it is, how big is it? */
  122.     float fontBBox[4];        /* bounding box (llx lly urx ury) */
  123.     float underlinePosition;    /* dist from basline for underlines */
  124.     float underlineThickness;    /* thickness of underline stroke */
  125.     char *version;        /* version identifier */
  126.     char *notice;        /* trademark or copyright */
  127.     char *encodingScheme;    /* default encoding vector */
  128.     float capHeight;        /* top of 'H' */
  129.     float xHeight;        /* top of 'x' */
  130.     float ascender;        /* top of 'd' */
  131.     float descender;        /* bottom of 'p' */
  132. #ifdef m68k
  133.     short hasYWidths;        /* do any chars have non-0 y width? */
  134. #endif
  135.     float *widths;        /* character widths in x */
  136.     unsigned int widthsLength;
  137.     char *strings;        /* table of strings and other info */
  138.     unsigned int stringsLength;
  139. #ifndef m68k
  140.     short hasYWidths;
  141. #endif
  142.     char hasXYKerns;        /* Do any of the kern pairs have nonzero dy? */
  143.     char reserved;
  144.     short *encoding;        /* 256 offsets into charMetrics */
  145.     float *yWidths;        /* character widths in y.  NOT in encoding */
  146.         /* order, but a parallel array to the charMetrics array */
  147.     NXCharMetrics *charMetrics;        /* array of NXCharMetrics */
  148.     int numCharMetrics;            /* num elements */
  149.     NXLigature *ligatures;        /* array of NXLigatures */
  150.     int numLigatures;            /* num elements */
  151.     NXEncodedLigature *encLigatures;    /* array of NXEncodedLigatures */
  152.     int numEncLigatures;        /* num elements */
  153.     union {
  154.     NXKernPair *kernPairs;        /* array of NXKernPairs */
  155.     NXKernXPair *kernXPairs;    /* array of NXKernXPairs */
  156.     } kerns;
  157.     int numKernPairs;            /* num elements */
  158.     NXTrackKern *trackKerns;        /* array of NXTrackKerns */
  159.     int numTrackKerns;            /* num elements */
  160.     NXCompositeChar *compositeChars;    /* array of NXCompositeChar */
  161.     int numCompositeChars;        /* num elements */
  162.     NXCompositeCharPart *compositeCharParts; /* array of NXCompositeCharPart */
  163.     int numCompositeCharParts;        /* num elements */
  164. #ifdef KANJI
  165.     char isBaseFont;            /* true if base font */
  166. #ifndef m68k
  167.     char hasCharWidth;
  168. #endif m68k
  169.     int mappingScheme;            /* for composite font only */
  170.     int metricsSet;            /* for vertical writing */
  171.     int characters;            /* number of character defined */
  172.     float charWidth[2];            /* fixed pitch font width */
  173. #ifdef m68k
  174.     char hasCharWidth;
  175. #endif m68k
  176.     char *characterSet;            /* font specific/ Do not refer */
  177.     unsigned char widthsIndex[256];    /* index for widths */
  178.     unsigned char maxIndex;        /* maximum index */
  179.     short cfFlags;            /* flags for composite font */
  180.     void *_compositeFontInfo;
  181.     int _reserved[4];            /* for future use */
  182. #endif KANJI
  183. } NXFontMetrics;
  184.  
  185. #endif AFM_H
  186.  
  187.